<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IP输入</title>
    <link rel="stylesheet" href="css/ipBox.css">
    <style>
        .ip1 , .ip2{
            display: inline-block;
            margin:10px;
        }
    </style>
</head>
<body>
    <div class="ip1"></div>

    <div class="ip2"></div>

    <div class="ip3"></div>

</body>
<script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="js/jquery.ipBox.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
        $(".ip1").ipBox({
            port : true,
            portIn: true,
            titleText : "ip段",
            titleOut : true,
            ipValue : "172.168.108.0/24",
            noPoint : false
        });
        $(".ip2").ipBox({
            port : true,
            portIn: false,
            titleText : "ip段",
            ipValue : "172.168.109.0/18",
            titleOut : true,
            noPoint : false
        });

        $(".ip3").ipBox({
            port: false,
            titleOut: true,
            ipValue : "",
            filter: /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))((\;(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))*)$/
        })

        function strToArr(str,port){
            var arr=str.split(".");
            var arr1=[];
            if(port){
                arr1=arr1.concat(arr.slice(0,arr.length-1),arr[arr.length-1].split("/"));
            }else{
                arr1=arr;
            }
            console.log(arr1);
        }
        var str = "172.168.108.24";
        strToArr(str,true);
    })
</script>
</html>